home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / UTILITY / DOSPAS10.ARJ / DOSPASS.C next >
C/C++ Source or Header  |  1991-11-14  |  2KB  |  111 lines

  1. /*
  2.  * DOSpass v1.0    Author: Daniel Sherer     November, 1991
  3.  *
  4.  *     Ferrets out the passwords from the 'DOSSHELL' v5.0 menu system.
  5.  */
  6.  
  7. static    char    Ident[] = {"DOSpass  v1.0  By: Daniel Sherer, Nov 91"};
  8.  
  9. #include <stdio.h>
  10. #include "string.h"
  11.  
  12. #define MAXLEN    1024
  13. #define NULL    0
  14. #define    TRUE    (1)
  15. #define FALSE    (0)
  16. #define EOF    (-1)
  17. #define NL    0x0A
  18. #define CR    0x0D
  19.  
  20. main(argc, argv)
  21.     int    argc;
  22.     char    **argv;
  23. {
  24.     FILE    *ini_file;
  25.     char    byte, buffer[MAXLEN];
  26.     int    no_more_lines;
  27.     int    sub;
  28.     char    filepath[40];
  29.     char    title[41], passwd[41];
  30.     char    *bptr;
  31.  
  32.     if( argc < 2 ) {
  33.         strcpy(filepath,"\\dos");
  34.         printf("\n\rScanning default directory (%s).\r\n\n", filepath);
  35.     }
  36.     else {
  37.         strcpy(filepath,argv[1]);
  38.     }
  39.     strcat(filepath,"\\dosshell.ini");
  40.     if((ini_file=fopen(filepath,"r")) == NULL) {
  41.         printf("\r\nCannot open file '%s'\r\n\n", filepath);
  42.         exit(10);
  43.     }
  44.  
  45.     no_more_lines  = FALSE;
  46.     title[0] = passwd[0] = NULL;
  47.  
  48.     while ( ! no_more_lines) {
  49.         bptr = buffer;
  50.         while ((byte = getc(ini_file)) != EOF) {
  51.             if (byte == NL)
  52.                 break;
  53.             else
  54.                 *bptr++ = byte;
  55.         }
  56.  
  57.         *bptr = NULL;
  58.         no_more_lines = feof(ini_file);
  59.  
  60.         bptr=strstr(buffer,"color =");    /* Did we find 'color =' ? */
  61.         if (bptr)
  62.             if (bptr == buffer)    /* At the Begining of line? */
  63.                 break;        /* We're done! */
  64.  
  65.         bptr=strstr(buffer,"program =");
  66.         if (bptr) {
  67.             if (title[0] > NULL) 
  68.                 showitem(&title, &passwd);
  69.             
  70.             title[0]   = NULL;
  71.             passwd[0]  = NULL;
  72.             continue;
  73.         }
  74.         bptr=strstr(buffer,"title =");
  75.         if (bptr) {
  76.             for (bptr+=8,sub=0; *bptr!=NULL; bptr++) {
  77.                 title[sub++] = *bptr;
  78.                 if (sub > 40) {
  79.                     title[40] = NULL;
  80.                     continue;
  81.                 }
  82.             }
  83.             title[sub] = NULL;
  84.         }
  85.         bptr=strstr(buffer,"password =");
  86.         if (bptr) {
  87.             for (bptr+=11,sub=0; *bptr!=NULL; bptr++) {
  88.                 passwd[sub++] = *bptr;
  89.                 if (sub > 40) {
  90.                     passwd[40] = NULL;
  91.                     continue;
  92.                 }
  93.             }
  94.             passwd[sub] = NULL;
  95.         }
  96.     }
  97.     if (title[0])
  98.         showitem(&title, &passwd);
  99.  
  100.     printf("\r\nIf present, passwords appear in {}\r\n");
  101.     exit(0);
  102. }
  103. showitem(t,p)
  104.     char    *t, *p;
  105. {
  106.     if (*p != NULL)
  107.         printf("Menu Item-> %s \t{%s}\r\n", t, p);
  108.     else
  109.         printf("Menu Item-> %s\r\n", t);
  110. }
  111.